<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>发布评论</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
</head>
<body>
	
<div class="mui-content">
	<div class="mui-input-row" style="margin-left: 8px;margin-right: 8px;margin-top: 10px;">
		<textarea id="text-area-id" rows="5" cols="" placeholder="请输入内容..." value="" style="border-radius: 5px; font-size: 15px;margin-bottom: 0px; padding:8px 10px;"></textarea>
	</div>
	<div style="margin-top: 5px; text-align: right;color: darkgray;font-size: 13px;padding-right: 20px;">
		已输入字数 <span id="text-number-id">0/100</span> 
	</div>
	<!-- <button id="submit-button-id" type="button" class="mui-btn mui-btn-block" style="border-bottom-width: 0; background-color: orange;color: white; font-size: 15px; position: fixed;bottom: 0;margin-bottom: 0;height: 45px;">看看大伙说的啥</button> -->
</div>

<script src="../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/hud.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/user.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/open.page.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var maxTextLen = 100;//最大输入长度
	mui.init({
		beforeback:function () {
			var last = plus.webview.getWebviewById('home-detail.html');
			mui.fire(last , 'refresh-comment-event');
		}
	})
	
	mui.plusReady(function () {
		var textArea = document.getElementById('text-area-id');
		textArea.addEventListener('input' , function(){
			var _content = this.value;
			var strLen = _content.length;
			if(strLen >= maxTextLen){
				var s = _content.substring(0,maxTextLen);
				this.value = s;
				mui.alert('最多只能输入' + maxTextLen + '字符');
			}
			
			document.getElementById('text-number-id').innerText = this.value.length + '/100';
		})
		

		var wv = plus.webview.currentWebview();
		var dtInfo = wv.dtInfo;
		wv.setStyle({
			titleNView:{
					buttons:[{
					color:'#FF4500',
					text:'提交 ',
					width:'60px',
					fontSize:'14px',
					float:'right', //按钮不像绘制的方法，是不能用position绝对定位的，只能左右浮动
					onclick:submitAction 
					}]
					
				}
		}) ;
		
		function submitAction(){
				var _text = textArea.value;
				if(_text.length < 1){mui.alert('输入内容不能为空!');return;}
				var uid = getLoginUid();
				if(uid == null){return;}
				
				var d = {"content" : _text , "type":"add" , "uid":getLoginUid()};
						 
				hud_show('提交中!');	
				api_post(feedback_url , d , function(res){
					hud_close('提交成功,感谢你的宝贵意见');
					setTimeout(function(){
						mui.back();
					},1000);
				},function(error){
					hud_close(error);
				})
		}
		
		//看看大伙说的啥
		// document.getElementById('submit-button-id').addEventListener('tap',function(){
		// 	openNewPage('../me/webpage.html' , '反馈列表' , true , {'url':BASE_URL + feedbackList_url});	
		// })
	});
</script>
</body>
</html>